//
//  SFBasicTableViewController.swift
//  SFWeiBo
//
//  Created by 孙凡 on 16/4/8.
//  Copyright © 2016年 Edward. All rights reserved.
//

import UIKit

class SFBasicTableViewController: UITableViewController,SFVisitorViewDelegate {

    var isLogin:Bool = SFUserAccountViewModel.sharedAccountViewModel.userLogin
//    var isLogin:Bool = false

    override func viewDidLoad() {
        super.viewDidLoad()

        self.navigationItem.title = self.tabBarItem.title

    }


    override func loadView() {

        if isLogin {

            super.loadView()

        } else {

            setView()


        }


    }




    func setView(){

        let v = visitorView



        navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: nil, title: "注册", target: self, SEL: #selector(SFBasicTableViewController.login))
        navigationItem.rightBarButtonItem = UIBarButtonItem(imageName: nil, title: "登陆", target: self, SEL: #selector(SFBasicTableViewController.login))

        visitorView.delegate = self
        

        view = v

    }
    @objc private func login(){

        visitorViewRegisterBtnDidClick(nil, button: nil)

    }


    //懒加载view
    lazy var visitorView:SFVisitorView = SFVisitorView()


    //MARK: - 代理方法
    func visitorViewRegisterBtnDidClick(view: SFVisitorView?, button: UIButton?) {

        let vc = SFOAuthViewController()

        presentViewController(SFNvgViewController(rootViewController: vc), animated: true, completion: nil)
    }

}
